import { _t } from "@/tools/index";
const { langConfig } = require("./config");

/**语言列表 */
export const langList = langConfig.map((item) => item.abbreviation);

/**语言库 */
export const resources = (() => {
  const _resources = {};
  langConfig.map((item) => {
    _resources[item.abbreviation] = {
      translation: item.translation,
    };
  });
  return _resources;
})();

/**语言库选择器 */
export const getLangSource = () => {
  const _langConfig = langConfig.map((item) => {
    return {
      key: _t(item.translateKey),
      value: item.abbreviation,
    };
  });
  return _langConfig;
};

/**获取语言name */
export const getLangName = (lang) =>
  getLangSource().find((item) => item.value === lang)?.key || "";

/**获取语言value */
export const getLangValue = (lang) =>
  getLangSource().find((item) => item.value === lang)?.value || "";

/**默认语言 */
export const defaultLang = "zh_CN";

/**
 * replace: 语言替换
 * ReUploadThem
 * CongratulationsYou
 * AndOtherPeople
 */
